﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using CustomFilters.WebPartCode;

namespace CustomFilters.UserControls
{
    public partial class MultiSelectControl : System.Web.UI.UserControl, IHostedUserControlFilter
    {
        #region IHostedUserControlFilter Members

        public List<string> Values
        {
            get
            {
                return ListBox1.Items.Cast<ListItem>().Where(item => item.Selected).Select(q => q.Value).ToList();
            }
            set
            {
                foreach (string Item in value)
                {
                    ListBox1.Items.FindByValue(Item).Selected = true;
                }
            }
        }

        #endregion
    }
}